#初始化
def init_set():
    for i in range(10):
        s.append(i)
    #s = list(range(10))

#查询
def find_set(x):
    if x != s[x]:
       s[x] = find_set(s[x])   # 路径压缩
    return s[x]
    # if x == s[x]:    #无路径压缩
    #     return x
    # else:
    #     return find_set(s[x])

#合并
def merge_set(a, b):
    a = find_set(a)
    b = find_set(b)
    if a != b:
        s[a] = b

s = []
init_set()
for i in range(10):
    print('s[{0}] ='.format(i), s[i], end = ',')
print()
while True:
    a, b = list(map(int, input().split()))
    merge_set(a, b)
    for i in range(10):
        find_set(i)  # ← 新增这行
    for i in range(10):
        print('s[{0}] ='.format(i), s[i], end = ',')
    print()